home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / emerald / emrldsys.lha / EC / OperationNames / utils.c < prev   
Encoding:
C/C++ Source or Header  |  1990-08-16  |  518 b   |  28 lines

  1. #include <stdio.h>
  2.  
  3. void send(socket, string)
  4. int socket;
  5. char *string;
  6. {
  7.   int length = strlen(string) + 1;
  8.   if (write(socket, string, length) != length) {
  9.     fprintf(stderr, "Write failed on socket %d\n", socket);
  10.     fprintf(stderr, "String was \"%s\"\n", string);
  11.     abort();
  12.   }
  13. }
  14.  
  15. void receive(socket, string)
  16. int socket;
  17. char *string;
  18. {
  19.   int length;
  20.   length = read(socket, string, 4096);
  21.   if (length < 0) {
  22.     perror("receive: (read)");
  23.     abort();
  24.   } else if (length == 0) {
  25.     *string = '\0';
  26.   }
  27. }
  28.